import request from "@/utils/request";
import { RootThunkAction } from "../types/store";
import {ApiResponse,userInfo,Profile} from '../types/data'
// 获取用户基本资料的action
export const getProfile=():RootThunkAction=>{
    return async (dispatch)=>{
        // 1.发送登录的请求  
        // 本接口的返回值类型userInfo
        const res = await request.get<ApiResponse<userInfo>>('/user')
        console.log(res);
        // 3.存到redux
        dispatch({
            type:"profile/getUserInfo",
            payload:res.data.data
        })
        
    }
}
// 获取用户个人资料action
export const getUserProfile=():RootThunkAction=>{
    return async (dispatch)=>{
        // 1.发送验证码的请求
        const res=await request.get<ApiResponse<Profile>>('/user/profile')
        console.log(res);
         // 3.存到redux
         dispatch({
            type:"profile/getProfile",
            payload:res.data.data
        })
    }

}

